package com.cjjd.c.feature.mine.favorite;

import android.support.v4.app.FragmentActivity;
import android.text.Html;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.cjjd.c.R;
import com.cjjd.c.base.MyBaseAdapter;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * ----------------------------------
 * Created by xyd on 2017/8/15.
 * <p/>
 * 描  述：
 * <p/>
 * 修订历史:
 * ----------------------------------
 */

public class FavoriteAdapter extends MyBaseAdapter {
    public FavoriteAdapter(FragmentActivity mContext) {
        super(mContext);
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {


        ViewHolder viewHolder = null;
        if (convertView == null) {
            convertView = LayoutInflater.from(mContext).inflate(R.layout.item_favorite, parent, false);
            viewHolder = new ViewHolder(convertView);
            convertView.setTag(viewHolder);
        } else {
            viewHolder = (ViewHolder) convertView.getTag();
        }

//        String str = "<font color= 'red'>"+"￥1200"+"</font>"
//                + "<font color='#999999'>起</font>";
//        viewHolder.tvPrice.setText(Html.fromHtml(str));

        return convertView;
    }


    /**
     * 设置html格式的颜色值
     *
     * @param text  需要设置的文本
     * @param color 需要设置的颜色：#ffffff
     * @return
     */
    public  String setHtmlColor(String text, String color) {

        return "<font color=\"" + color + "\">" + text + "</font>";
    }

    static class ViewHolder {
        @Bind(R.id.iv_favorite)
        ImageView ivFavorite;
        @Bind(R.id.tv_name)
        TextView tvName;
        @Bind(R.id.tv_grade)
        TextView tvGrade;
        @Bind(R.id.tv_address)
        TextView tvAddress;
        @Bind(R.id.tv_price)
        TextView tvPrice;

        ViewHolder(View view) {
            ButterKnife.bind(this, view);
        }
    }
}
